package com.iaz.tech.tools.common.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson2.JSON;
import com.iaz.tech.tools.common.AIToolsCommon;

/**
 * @apiNote     用于广泛操作java.reflect ， 用于对object 的属性值， Method 调用
 * @author      Zhao limin 
 * @version     2022.09
 */
public class PropertyTools {
    /** 
     * 日志
     */
	private final static Logger logger = (Logger) LoggerFactory.getLogger(PropertyTools.class);

    private static float ZERO_FLOAT_VALUE_LIMMIT = 0.0000f;
	private static double ZERO_DOUBLE_VALUE_LIMIT = 0.0000000001;

     /**
     * 利用递归，查询type ，type 的superClass, 或者implements 匹配superClass
     * @param superClass
     * @param type
     * @return
     */
    public static boolean instanceofClass(Class<?> superClass,  Class<?> type ){
        boolean result = false;
        try{
            if( type == null ){
                throw new IllegalArgumentException("入口参数type 需要指定！");
            }
            if( superClass == null ){
                throw new IllegalArgumentException("入口参数superClass 需要指定！");
            }
            if(superClass.equals(type) ){
                result = true;
                return result;
            }

            List<Class<?>> super_class_queue = new ArrayList<>();

            super_class_queue.add(type);
            while(!super_class_queue.isEmpty()){
                /* 出队 */
                Class<?> queue_type = super_class_queue.remove(0);
                if( queue_type == null ) continue;

                if(queue_type.equals(superClass) ){
                    result = true;
                    return result;
                }

                Class<?>[] interfaces = queue_type.getInterfaces();
                if( interfaces != null ){
                    for(Class<?> interface_class :  interfaces){
                        if( interface_class.equals(superClass)){
                            result = true;
                            break;
                        }
                    }
                    if( result ){
                        break;
                    }
                }

                Class<?> super_class = queue_type.getSuperclass();
                if( super_class.equals( superClass )){
                    result = true;
                    break;
                }else {
                    /* 入队 */
                    super_class_queue.add( super_class );
                }
            }


        }catch(Exception e){
            logger.error("调用PropertyTools.instanceofClass异常：" + e.getMessage());
        }

        return result;
    }

    /**
     * @apiNote     如果是基础类型则转换成字符串
     * @version     2022.09
     * @author      Zhao limin
     */
    public static String toStringWithObjJson(Class<?> type, Object value ){
        String result = "";
        try{
            if( value == null ){ 
                return result;
            }
            if( type == null ){
                result = value.toString();
            }

            if( type == char.class){
                if( instanceofClass(char.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
            }
            else if( type == byte.class){ 
                if( instanceofClass(byte.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
            }
            else if( type == Byte.class){ 
                if( instanceofClass(Byte.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
            }
            else if( type == short.class){ 
                if( instanceofClass(short.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
                
            }
            else if( type == Short.class){ 
                if( instanceofClass(Short.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
            }
            else if( type == int.class){ 
                if( instanceofClass(int.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
                
            }
            else if( type == Integer.class){ 
                if( instanceofClass(Integer.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
            }
            else if( type == long.class){ 

                if( instanceofClass(long.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
            }
            else if( type == Long.class){ 
                if( instanceofClass(Long.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
            }
            else if( type == float.class){ 

                if( instanceofClass(float.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }
            }
            else if( type == Float.class){ 
                if( instanceofClass(Float.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }                
            }
            else if( type == double.class){ 
                if( instanceofClass(double.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }                
            }
            else if( type == Double.class){ 
                if( instanceofClass(Double.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }    
            }
            else if( type == boolean.class){ 
                if( instanceofClass(boolean.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }                   
            }
            else if( type == Boolean.class){ 
                if( instanceofClass(Boolean.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }  
            }
            else if( type == Enum.class){ 
                if( instanceofClass(Enum.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }  
                
            }
            else if( type == String.class){ 
                if( instanceofClass(String.class, value.getClass()) ){
                    result = String.valueOf(value);
                }else{
                    result = value.toString();
                }  
            }
            else if( type == Date.class){ 

                if( instanceofClass(Date.class, value.getClass()) ){
                    result = UtilTools.fromDate((Date)value, AIToolsCommon.DEFAULT_LONG_DATE_FORMAT);
                }else{
                    result = value.toString();
                }  
            }
            else {
                if( instanceofClass(type, value.getClass()) ){
                     result = JSON.toJSONString(value);
                } else { 
 
                    result = String.valueOf(value);
                }
            }

        }catch(Exception e){
            logger.error("将对象转换成String 异常：" + e.getMessage());
        }

        return result;
    }

    /**
     * 将字符串转成对象
     */
    public static Object strToValue(Class<?> type, String valueString) {
        Object result = null;
        try{
            if( type == null ){
                result = UtilTools.Trim(valueString);
                return result;
            }
            String tmpStringValue = UtilTools.Trim(valueString); 
            if( instanceofClass( char.class, type ) ){
                result = (char)Short.parseShort( tmpStringValue );
            }
            else if( type == byte.class){ 
                result = Byte.parseByte( tmpStringValue ); 
            }
            else if( type == Byte.class){ 
                result = Byte.parseByte( tmpStringValue ); 
            }
            else if( type == short.class){ 
                result = Short.parseShort( tmpStringValue );                
            }
            else if( type == Short.class){ 
                result = Short.parseShort( tmpStringValue );   
            }
            else if( type == int.class){ 
                result = Integer.parseInt( tmpStringValue );                
            }
            else if( type == Integer.class){ 
                result = Integer.parseInt( tmpStringValue );    
            }
            else if( type == long.class){ 
                result = Long.parseLong( tmpStringValue ); 
            }
            else if( type == Long.class){ 
                result = Long.parseLong( tmpStringValue );
            }
            else if( type == float.class){ 
                result = Float.parseFloat( tmpStringValue ) ;                
            }
            else if( type == Float.class){ 
                result = Float.parseFloat( tmpStringValue ) ;              
            }
            else if( type == double.class){ 
                result = Double.parseDouble( tmpStringValue ) ;               
            }
            else if( type == Double.class){ 
                result = Double.parseDouble( tmpStringValue ) ;  
            }
            else if( type == boolean.class){ 
                result = Boolean.parseBoolean( tmpStringValue );                
            }
            else if( type == Boolean.class){ 
                result = Boolean.parseBoolean( tmpStringValue ); 
            }
            else if( type.isEnum()){  
                
                for( Object enumObj :type.getEnumConstants() ){
                    String vname = UtilTools.Trim( enumObj.toString() );
                    if( vname.equals(tmpStringValue)){
                        result = enumObj;
                        break;
                    }
                }
            }
            else if( type == String.class){ 
                result = UtilTools.Trim( tmpStringValue );
            }
            else if( type == Date.class){ 
                result = UtilTools.toDate( tmpStringValue);
            }
            else {
                result = JSON.parseObject(tmpStringValue, type);
                
            }

        }catch(Exception e) {
            logger.error("PropertyTools调用strToValue 异常：" + e.getMessage());
        } 
        return result;
    }


    /**
	 * 根据map中KEY 值，从obj 读取set{KEY}方法是否存在，返回匹配的kEY值
	 * @param map           配置
	 * @param obj           对象（必须不能为null)
	 * @return
	 * @throws Exception
	 */
	public static List<String> indexAndGetMapWithoutKeys(Map<String,Object> map, Object obj) throws Exception{
		List<String> result = new ArrayList<String>();
		
		if( map ==null ) return result;
		if( map.size() == 0 ) return result;
		if( obj == null ) return result;
		
		Method[] methods = obj.getClass().getMethods();
		if( methods == null ) return result;
		if( methods.length == 0 ) return result;
		
		for(Map.Entry<String, Object> entry : map.entrySet() ){
			if(UtilTools.IsNull( entry.getKey())) continue;
			
			String tmp_key = UtilTools.Trim( entry.getKey() );
			
			String methodName = "set"+ tmp_key.substring( 0,1).toUpperCase() + tmp_key.substring(1);
			
			boolean isExists = false;
			
			for( Method _method : methods){
				if( _method == null ) continue;
				
				String method_name = UtilTools.Trim( _method.getName() );
				if( method_name.equals( methodName)){
					isExists = true;
					break;
				}
			}
			if( !isExists){
				result.add(entry.getKey());
			} 
		} 		
		return result;
	}

    /**
	 * 将KEY, 在obj 不存在以set+{KEY}为名称方法的KEY
	 * @param map
	 * @param obj
	 * @throws Exception
	 */
	public static void confirmMapAndObjecMethodsAndDeleteNoSet(Map<String,Object> map, Object obj) throws Exception{
		if( map == null ) return;
		if( obj == null ) return;
		
		List<String> keys = indexAndGetMapWithoutKeys(map, obj);
		if( keys == null ) return ;
		if( keys.size() == 0 ) return;
		
		for( String _key : keys){
			if( UtilTools.IsNull(_key )) continue;
			if( map.containsKey( _key )){
				map.remove( _key );
			}
		}
	}

    /**
	 * 将对象的方法，及值填充到map(当前层）
	 * @param map
	 * @param obj
	 * @throws Excetpion
	 */
	public static void pushObjectGetMethodForMap(Map<String,Object> map, Object obj ) throws Exception{
		if( map ==null ) return ; 
		if( obj == null ) return ;
		
		Method[] methods = obj.getClass().getMethods();
		if( methods == null ) return ;
		if( methods.length == 0 ) return ;
		
		for( Method _method : methods){
			String method_name = UtilTools.Trim( _method.getName() );
			try{
				if( method_name.indexOf("get") == 0 ){
					String key_name = UtilTools.Trim( method_name.substring( "get".length())  );
					if( UtilTools.IsNull( key_name )) continue;
					/* 执行 */
					Object o_value = _method.invoke(obj );
					if( o_value != null ){
						map.put( key_name, o_value);
					}
				}
			}catch(Exception e){
				
			}
		}		
	}
	
	public static Method getSETMethodForObjectByKey( Object obj, String map_key_string) throws Exception{
		Method result = null;
		
		try{
			if( obj == null ){
				throw new java.lang.IllegalArgumentException("transMap2Bean 调用异常，入口参数obj 需要指定。");
			}
			if( UtilTools.IsNull( map_key_string ) ){
				throw new java.lang.IllegalArgumentException("transMap2Bean 调用异常，入口参数map_key_string 需要指定。");
			}
			Method[] methods = obj.getClass().getMethods();
			if( methods == null ) return result;
			if( methods.length == 0 ) return result;
			
			String confireName = UtilTools.Trim( map_key_string );
			
			for( Method _method : methods){
				String method_name = UtilTools.Trim( _method.getName() );
				try{
					if( method_name.indexOf("set") == 0 ){
						String key_name = UtilTools.Trim( method_name.substring( "set".length())  );
						if( UtilTools.IsNull( key_name )) continue;
						/* 执行 */
						String method_name_key = key_name.substring(0,1).toLowerCase() + key_name.substring(1);
						
						if( _method.getParameterCount() != 1 ) continue;
						if( method_name_key.equals( confireName )){
							result = _method;
							break;
						}
					}
				}catch(Exception e){
					continue; 
				}
			}		
			
		}catch(Exception e){
			e.printStackTrace();			
		}
		
		return result;
	}
	
	/**
	 * 将obj 转换Map<String,Object> 模式
	 * 并且只支持单层
	 * @param obj
	 * @return
	 */
	public static Map<String,Object> BeanToMap(Object obj){
		Map<String,Object> result = new HashMap<String, Object>();
		try{
			if( obj == null ) return result;

			Method[] methods = obj.getClass().getMethods();
			if( methods == null ) return  result;
			if( methods.length == 0 ) return  result; 
		
			for( Method _method : methods){
				String method_name = UtilTools.Trim( _method.getName() );
				try{
					if( method_name.indexOf("get") == 0 ){

						String key = UtilTools.Trim( method_name.substring( "get".length() ) );
						key = key.substring(0,1).toLowerCase() + key.substring( 1);

						Object value = _method.invoke( obj);
						if( value != null ){
							result.put(key, value);
						}
					}
				}catch(Exception e){
					
				}
			}	 
		}catch(Exception e){
			logger.error("ObjToBean 出现异常！" );			
		}
		return result;
	}
	
	
	/**
	 * 替换， 将map 和对象的值进行映射
	 * @param map
	 * @param obj
	 */
	public static void transMap2Bean(Map<String,Object> map, Object obj) {
		try{
			if( map == null ){
				throw new java.lang.IllegalArgumentException("transMap2Bean 调用异常，入口参数map 需要指定。");
			}
			if( obj == null ){
				throw new java.lang.IllegalArgumentException("transMap2Bean 调用异常，入口参数obj 需要指定。");
			}
			
			if( map.size() == 0 ) return;
			
			for( Map.Entry<String, Object> entry : map.entrySet()){
				if( UtilTools.IsNull( entry.getKey() )) continue;
				String propertyName = UtilTools.Trim( entry.getKey() );
				try{
					Method _method = getSETMethodForObjectByKey( obj, propertyName );
					if( _method == null ) continue;
					
					Parameter parameter = _method.getParameters()[0];
					
					Type type = parameter.getParameterizedType();
					Object value = parserValue(type, String.valueOf( entry.getValue() ));
					_method.invoke( obj, value);
				}catch(Exception e){
					System.out.println("属性：" + propertyName + ",没有对应的方法。");
				}
			}
		}catch(Exception e){
			e.printStackTrace();
			
		}
	}
	
	public static void transMap2Bean(Map<String,Object> map, Object obj, String primaryKey) {
		try{
			if( map == null ){
				throw new java.lang.IllegalArgumentException("transMap2Bean 调用异常，入口参数map 需要指定。");
			}
			if( obj == null ){
				throw new java.lang.IllegalArgumentException("transMap2Bean 调用异常，入口参数obj 需要指定。");
			}
			
			String tmp_private_key = UtilTools.Trim(primaryKey);
			
			if( map.size() == 0 ) return;
			
			for( Map.Entry<String, Object> entry : map.entrySet()){
				try{
					if( UtilTools.IsNull( entry.getKey() )) continue;
					
					String tmp_key = UtilTools.Trim( entry.getKey() );
					/* 主键不更新 */
					if( tmp_key.equals( tmp_private_key )) continue;
					
					Method _method = getSETMethodForObjectByKey( obj, tmp_key );
					if( _method == null ) continue; 				
					
					Parameter parameter = _method.getParameters()[0];
					
					Type type = parameter.getParameterizedType();
					Object value = parserValue(type, String.valueOf( entry.getValue() ));
					_method.invoke( obj, value);
				}catch(Exception e){
					System.out.println("复制Map异常：" + e.getMessage());
				}
			}
		}catch(Exception e){
			e.printStackTrace();
			
		}
	} 

    public static int compare(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		int result = 0;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( byte.class)){ 
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result =  (byte_v1 - byte_v2 > 0)?1:(byte_v1 - byte_v2 == 0)?0:-1;
		}
		else if( dataType.equals(Byte.class)){
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result =  (byte_v1 - byte_v2 > 0)?1:(byte_v1 - byte_v2 == 0)?0:-1;
		}
		else if( dataType.equals(char.class)){
			 char char_v1 = toChar( o_v1 );
			 char char_v2 = toChar( o_v2 );
			 result =  (char_v1 - char_v2 > 0)?1:(char_v1 - char_v2 == 0)?0:-1;
		}  
		 
		else if( dataType.equals( Short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  (short_v1 - short_v2 > 0)?1:(short_v1 - short_v2 == 0)?0:-1;
		}	
		else if( dataType.equals( short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  (short_v1 - short_v2 > 0)?1:(short_v1 - short_v2 == 0)?0:-1;
		} 
		else if(  dataType.equals( int.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  (int_v1 - int_v2 > 0)?1:(int_v1 - int_v2 == 0)?0:-1;
		}
		else if(  dataType.equals( Integer.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  (int_v1 - int_v2 > 0)?1:(int_v1 - int_v2 == 0)?0:-1;
		}
		else if( dataType.equals( long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  (long_v1 - long_v2 > 0)?1:(long_v1 - long_v2 == 0)?0:-1;
		}
		else if( dataType.equals( Long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  (long_v1 - long_v2 > 0)?1:(long_v1 - long_v2 == 0)?0:-1;
		} 
		else if( dataType.equals( float.class)){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			 
			if( Math.abs( float_v1 - float_v2 ) < ZERO_FLOAT_VALUE_LIMMIT ){
				result = 0;
			}else if( float_v1 - float_v2 < 0 ){
				result = -1;
			}else{
				result = 1;
			} 
		}
		else if( dataType.equals(Float.class )){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			if( Math.abs( float_v1 - float_v2 ) < ZERO_FLOAT_VALUE_LIMMIT ){
				result = 0;
			}else if( float_v1 - float_v2 < 0 ){
				result = -1;
			}else{
				result = 1;
			} 
		}
		else if( dataType.equals( double.class )){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );	
			
			if( Math.abs( double_v1 - double_v2 ) < ZERO_DOUBLE_VALUE_LIMIT ){
				result = 0;
			}else if( double_v1 - double_v2 < 0 ){
				result = -1;
			}else{
				result = 1;
			}   
		}
		else if( dataType.equals( Double.class ) ){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			if( Math.abs( double_v1 - double_v2 ) < ZERO_DOUBLE_VALUE_LIMIT ){
				result = 0;
			}else if( double_v1 - double_v2 < 0 ){
				result = -1;
			}else{
				result = 1;
			} 
		}
		else if( dataType.equals( boolean.class )  ){
			boolean bool_v1 = toBoolean( o_v1 );
			boolean bool_v2 = toBoolean( o_v2 ); 
			
			if( bool_v1 && bool_v2){
				result = 0;
			}else if( bool_v1 ){
				result = 1;
			}else {
				result = 0;
			}
			
		}
		else if( dataType.equals( Boolean.class )  ){
			boolean bool_v1 = toBoolean( o_v1 );
			boolean bool_v2 = toBoolean( o_v2 );
			
			if( bool_v1 && bool_v2){
				result = 0;
			}else if( bool_v1 ){
				result = 1;
			}else {
				result = 0;
			}
		}
		else if( dataType.equals( Date.class ) ){
			 Date date_v1 = toDate( o_v1 );
			 Date date_v2 = toDate( o_v2 );
			 
			 long long_v1 = date_v1.getTime();
			 long long_v2 = date_v2.getTime();
			 
			 result =  (long_v1 - long_v2 > 0)?1:(long_v1 - long_v2 == 0)?0:-1;
			 
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			
			long long_v1 = date_v1.getTime();
			long long_v2 = date_v2.getTime();
			 
			result =  (long_v1 - long_v2 > 0)?1:(long_v1 - long_v2 == 0)?0:-1;
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			
			long long_v1 = sqlTime_v1.getTime();
			long long_v2 = sqlTime_v2.getTime(); 
			result =  (long_v1 - long_v2 > 0)?1:(long_v1 - long_v2 == 0)?0:-1; 
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			
			long long_v1 = sqlTime_v1.getTime();
			long long_v2 = sqlTime_v2.getTime(); 
			result =  (long_v1 - long_v2 > 0)?1:(long_v1 - long_v2 == 0)?0:-1; 
		}
		 else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 )); 
			 
			 result = s_v1.compareTo( s_v2);
			 result = result > 0 ? 1:result == 0?0:-1;
		} 
		return result;
	}
	
	/**
	 * 相同
	 * @param dataType
	 * @param o_v1
	 * @param o_v2
	 * @return
	 * @throws Exception
	 */
	public static boolean equals(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( byte.class)){
			
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 == byte_v2);
		}
		else if( dataType.equals(Byte.class)){
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 == byte_v2);
		}
		else if( dataType.equals(char.class)){
			 char char_v1 = toChar( o_v1 );
			 char char_v2 = toChar( o_v2 );
			 result =  ( char_v1 == char_v2 );
		}  
		 
		else if( dataType.equals( Short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 == short_v2 );
		}	
		else if( dataType.equals( short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 == short_v2 );
		} 
		else if(  dataType.equals( int.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 == int_v2 );
		}
		else if(  dataType.equals( Integer.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 == int_v2 );
		}
		else if( dataType.equals( long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 == long_v2 );
		}
		else if( dataType.equals( Long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 == long_v2 );
		} 
		else if( dataType.equals( float.class)){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = Math.abs( float_v1 - float_v2 ) < ZERO_FLOAT_VALUE_LIMMIT;
		}
		else if( dataType.equals(Float.class )){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = Math.abs( float_v1 - float_v2 ) < ZERO_FLOAT_VALUE_LIMMIT;
		}
		else if( dataType.equals( double.class )){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = Math.abs( double_v1 - double_v2 ) < ZERO_DOUBLE_VALUE_LIMIT;
		}
		else if( dataType.equals( Double.class ) ){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = Math.abs( double_v1 - double_v2 ) < ZERO_DOUBLE_VALUE_LIMIT;
		}
		else if( dataType.equals( boolean.class )  ){
			boolean bool_v1 = toBoolean( o_v1 );
			boolean bool_v2 = toBoolean( o_v2 );
			result =  ( bool_v1==bool_v2 );
		}
		else if( dataType.equals( Boolean.class )  ){
			boolean bool_v1 = toBoolean( o_v1 );
			boolean bool_v2 = toBoolean( o_v2 );
			result =  ( bool_v1==bool_v2 );
		}
		else if( dataType.equals( Date.class ) ){
			 Date date_v1 = toDate( o_v1 );
			 Date date_v2 = toDate( o_v2 );
			 return ( date_v1.getTime() - date_v2.getTime() == 0);
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			return ( date_v1.getTime() - date_v2.getTime() == 0);
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() == 0);
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() == 0);
		}
		 else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 )); 
			 result = s_v1.equals( s_v2 ); 
		} 
		return result;
	}
	
	/**
	 * 相等
	 * @param dataType
	 * @param o_v1
	 * @param o_v2
	 * @return
	 * @throws Exception
	 */
	public static boolean notEquals(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( byte.class)){
			
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 != byte_v2);
		}
		else if( dataType.equals(Byte.class)){
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 != byte_v2);
		}
		else if( dataType.equals(char.class)){
			 char char_v1 = toChar( o_v1 );
			 char char_v2 = toChar( o_v2 );
			 result =  ( char_v1 != char_v2 );
		}  
		 
		else if( dataType.equals( Short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 != short_v2 );
		}	
		else if( dataType.equals( short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 != short_v2 );
		} 
		else if(  dataType.equals( int.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 != int_v2 );
		}
		else if(  dataType.equals( Integer.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 != int_v2 );
		}
		else if( dataType.equals( long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 != long_v2 );
		}
		else if( dataType.equals( Long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 != long_v2 );
		} 
		else if( dataType.equals( float.class)){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = Math.abs( float_v1 - float_v2 ) >ZERO_FLOAT_VALUE_LIMMIT;
		}
		else if( dataType.equals(Float.class )){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = Math.abs( float_v1 - float_v2 ) > ZERO_FLOAT_VALUE_LIMMIT;
		}
		else if( dataType.equals( double.class )){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = Math.abs( double_v1 - double_v2 ) > ZERO_DOUBLE_VALUE_LIMIT;
		}
		else if( dataType.equals( Double.class ) ){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = Math.abs( double_v1 - double_v2 ) > ZERO_DOUBLE_VALUE_LIMIT;
		}
		else if( dataType.equals( boolean.class )  ){
			boolean bool_v1 = toBoolean( o_v1 );
			boolean bool_v2 = toBoolean( o_v2 );
			result =  ( bool_v1 != bool_v2 );
		}
		else if( dataType.equals( Boolean.class )  ){
			boolean bool_v1 = toBoolean( o_v1 );
			boolean bool_v2 = toBoolean( o_v2 );
			result =  ( bool_v1 != bool_v2 );
		}
		else if( dataType.equals( Date.class ) ){
			 Date date_v1 = toDate( o_v1 );
			 Date date_v2 = toDate( o_v2 );
			 return ( date_v1.getTime() - date_v2.getTime() != 0);
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			return ( date_v1.getTime() - date_v2.getTime() != 0);
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() != 0);
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() != 0);
		}
		 else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 )); 
			 result = !s_v1.equals( s_v2 ); 
		} 
		return result;
	}
	
	public static boolean lower(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( byte.class)){
			
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 < byte_v2);
		}
		else if( dataType.equals(Byte.class)){
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 < byte_v2);
		}
		else if( dataType.equals(char.class)){
			 char char_v1 = toChar( o_v1 );
			 char char_v2 = toChar( o_v2 );
			 result =  ( char_v1 < char_v2 );
		}  
		 
		else if( dataType.equals( Short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 < short_v2 );
		}	
		else if( dataType.equals( short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 < short_v2 );
		} 
		else if(  dataType.equals( int.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 < int_v2 );
		}
		else if(  dataType.equals( Integer.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 < int_v2 );
		}
		else if( dataType.equals( long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 < long_v2 );
		}
		else if( dataType.equals( Long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 < long_v2 );
		} 
		else if( dataType.equals( float.class)){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = float_v1 < float_v2;
		}
		else if( dataType.equals(Float.class )){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = float_v1 < float_v2;
		}
		else if( dataType.equals( double.class )){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = double_v1 < double_v2;
		}
		else if( dataType.equals( Double.class ) ){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = double_v1 < double_v2;
		}
		else if( dataType.equals( boolean.class )  ){
			result = false;
		}
		else if( dataType.equals( Boolean.class )  ){ 
			result = false;
		}
		else if( dataType.equals( Date.class ) ){
			 Date date_v1 = toDate( o_v1 );
			 Date date_v2 = toDate( o_v2 );
			 return ( date_v1.getTime() - date_v2.getTime() < 0);
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			return ( date_v1.getTime() - date_v2.getTime() < 0);
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() < 0);
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() < 0);
		}
		 else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 )); 
			 result = s_v1.compareTo( s_v2 ) < 0; 
		} 
		return result;
	}
	
	
	
	/**
	 * 处理小于等于
	 * @param dataType
	 * @param o_v1
	 * @param o_v2
	 * @return
	 * @throws Exception
	 */
	public static boolean notLarger(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( byte.class)){
			
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 <= byte_v2);
		}
		else if( dataType.equals(Byte.class)){
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 <= byte_v2);
		}
		else if( dataType.equals(char.class)){
			 char char_v1 = toChar( o_v1 );
			 char char_v2 = toChar( o_v2 );
			 result =  ( char_v1 <= char_v2 );
		}   
		else if( dataType.equals( Short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 <= short_v2 );
		}	
		else if( dataType.equals( short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 <= short_v2 );
		} 
		else if(  dataType.equals( int.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 <= int_v2 );
		}
		else if(  dataType.equals( Integer.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 <= int_v2 );
		}
		else if( dataType.equals( long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 <= long_v2 );
		}
		else if( dataType.equals( Long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 <= long_v2 );
		} 
		else if( dataType.equals( float.class)){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = ( float_v1 < float_v2 ) || Math.abs(float_v1 - float_v2 ) < ZERO_FLOAT_VALUE_LIMMIT;
		}
		else if( dataType.equals(Float.class )){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = ( float_v1 < float_v2 ) || Math.abs(float_v1 - float_v2 ) < ZERO_FLOAT_VALUE_LIMMIT;
		}
		else if( dataType.equals( double.class )){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = ( double_v1 < double_v2 ) || Math.abs( double_v1 - double_v2 ) < ZERO_DOUBLE_VALUE_LIMIT;
		}
		else if( dataType.equals( Double.class ) ){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = ( double_v1 < double_v2 ) || Math.abs( double_v1 - double_v2 ) < ZERO_DOUBLE_VALUE_LIMIT;;
		}
		else if( dataType.equals( boolean.class )  ){
			 result = false;
		}
		else if( dataType.equals( Boolean.class )  ){ 
			result = false;
		}
		else if( dataType.equals( Date.class ) ){
			 Date date_v1 = toDate( o_v1 );
			 Date date_v2 = toDate( o_v2 );
			 return ( date_v1.getTime() - date_v2.getTime() <= 0);
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			return ( date_v1.getTime() - date_v2.getTime() <= 0);
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() <= 0);
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() <= 0);
		}
		else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 )); 
			 result = ( s_v1.compareTo( s_v2 ) < 0 ) || s_v1.equals( s_v2 ) ; 
		} 
		return result;
	}
	
	public static boolean larger(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( byte.class)){
			
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 > byte_v2);
		}
		else if( dataType.equals(Byte.class)){
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 > byte_v2);
		}
		else if( dataType.equals(char.class)){
			 char char_v1 = toChar( o_v1 );
			 char char_v2 = toChar( o_v2 );
			 result =  ( char_v1 > char_v2 );
		}  
		 
		else if( dataType.equals( Short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 < short_v2 );
		}	
		else if( dataType.equals( short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 > short_v2 );
		} 
		else if(  dataType.equals( int.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 > int_v2 );
		}
		else if(  dataType.equals( Integer.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 > int_v2 );
		}
		else if( dataType.equals( long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 > long_v2 );
		}
		else if( dataType.equals( Long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 > long_v2 );
		} 
		else if( dataType.equals( float.class)){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = float_v1 > float_v2;
		}
		else if( dataType.equals(Float.class )){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = float_v1 > float_v2;
		}
		else if( dataType.equals( double.class )){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = double_v1 > double_v2;
		}
		else if( dataType.equals( Double.class ) ){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = double_v1 > double_v2;
		}
		else if( dataType.equals( boolean.class )  ){
			result = false;
		}
		else if( dataType.equals( Boolean.class )  ){ 
			result = false;
		}
		else if( dataType.equals( Date.class ) ){
			 Date date_v1 = toDate( o_v1 );
			 Date date_v2 = toDate( o_v2 );
			 return ( date_v1.getTime() - date_v2.getTime() > 0);
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			return ( date_v1.getTime() - date_v2.getTime() > 0);
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() > 0);
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() > 0);
		}
		 else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 )); 
			 result = s_v1.compareTo( s_v2 ) > 0; 
		} 
		return result;
	}
	
	/**
	 * 相似
	 * @param dataType
	 * @param o_v1
	 * @param o_v2
	 * @return
	 * @throws Exception
	 */
	public static boolean like(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false; 
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			 
			String date_v1_String = UtilTools.fromDate( date_v1, "yyyyMMdd");
			String date_v2_String = UtilTools.fromDate( date_v2, "yyyyMMdd");
			result = date_v1_String.indexOf(date_v2_String ) >= 0;
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( date_v1, "yyyyMMdd");
			String date_v2_String = UtilTools.fromDate( date_v2, "yyyyMMdd");
			result = date_v1_String.indexOf(date_v2_String ) >= 0;
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( sqlTime_v1, "yyyyMMdd HH:mm:ss");
			String date_v2_String = UtilTools.fromDate( sqlTime_v2, "yyyyMMdd HH:mm:ss");
			result = date_v1_String.indexOf(date_v2_String ) >= 0; 
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( sqlTime_v1, "HH:mm:ss");
			String date_v2_String = UtilTools.fromDate( sqlTime_v2, "HH:mm:ss");
			result = date_v1_String.indexOf(date_v2_String ) >= 0; 
		}
		 else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 ));  
			 result = s_v1.indexOf(s_v2 ) >= 0;
		}  
		return result;
	} 
	
	
	public static boolean notLike(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false; 
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			 
			String date_v1_String = UtilTools.fromDate( date_v1, "yyyyMMdd");
			String date_v2_String = UtilTools.fromDate( date_v2, "yyyyMMdd");
			result = date_v1_String.indexOf(date_v2_String ) < 0;
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( date_v1, "yyyyMMdd");
			String date_v2_String = UtilTools.fromDate( date_v2, "yyyyMMdd");
			result = date_v1_String.indexOf(date_v2_String ) < 0;
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( sqlTime_v1, "yyyyMMdd HH:mm:ss");
			String date_v2_String = UtilTools.fromDate( sqlTime_v2, "yyyyMMdd HH:mm:ss");
			result = date_v1_String.indexOf(date_v2_String ) < 0; 
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( sqlTime_v1, "HH:mm:ss");
			String date_v2_String = UtilTools.fromDate( sqlTime_v2, "HH:mm:ss");
			result = date_v1_String.indexOf(date_v2_String ) < 0; 
		}
		 else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 ));  
			 result = s_v1.indexOf(s_v2 ) < 0;
		}  
		return result;
	} 
	
	
	public static boolean likeLeft(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false; 
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			 
			String date_v1_String = UtilTools.fromDate( date_v1, "yyyyMMdd");
			String date_v2_String = UtilTools.fromDate( date_v2, "yyyyMMdd"); 
			result = date_v1_String.indexOf(date_v2_String) == 0;
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( date_v1, "yyyyMMdd");
			String date_v2_String = UtilTools.fromDate( date_v2, "yyyyMMdd");
			result = date_v1_String.indexOf(date_v2_String ) == 0;
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( sqlTime_v1, "yyyyMMdd HH:mm:ss");
			String date_v2_String = UtilTools.fromDate( sqlTime_v2, "yyyyMMdd HH:mm:ss");
			result = date_v1_String.indexOf(date_v2_String ) == 0; 
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( sqlTime_v1, "HH:mm:ss");
			String date_v2_String = UtilTools.fromDate( sqlTime_v2, "HH:mm:ss");
			result = date_v1_String.indexOf(date_v2_String ) == 0; 
		}
		 else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 ));  
			 result = s_v1.indexOf(s_v2 ) == 0;
		}  
		return result;
	} 
	
	public static boolean likeRight(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false; 
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			 
			String date_v1_String = UtilTools.fromDate( date_v1, "yyyyMMdd");
			String date_v2_String = UtilTools.fromDate( date_v2, "yyyyMMdd");
			
			int lastIndex = date_v1_String.lastIndexOf(date_v2_String );  
			result = ( lastIndex >= 0 ) && ( ( lastIndex + date_v2_String.length()) == date_v1_String.length()   );
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( date_v1, "yyyyMMdd");
			String date_v2_String = UtilTools.fromDate( date_v2, "yyyyMMdd");
			int lastIndex = date_v1_String.lastIndexOf(date_v2_String );  
			result = ( lastIndex >= 0 ) && ( ( lastIndex + date_v2_String.length()) == date_v1_String.length()   );
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( sqlTime_v1, "yyyyMMdd HH:mm:ss");
			String date_v2_String = UtilTools.fromDate( sqlTime_v2, "yyyyMMdd HH:mm:ss");
			int lastIndex = date_v1_String.lastIndexOf(date_v2_String );  
			result = ( lastIndex >= 0 ) && ( ( lastIndex + date_v2_String.length()) == date_v1_String.length()   );
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			
			String date_v1_String = UtilTools.fromDate( sqlTime_v1, "HH:mm:ss");
			String date_v2_String = UtilTools.fromDate( sqlTime_v2, "HH:mm:ss");
			int lastIndex = date_v1_String.lastIndexOf(date_v2_String );  
			result = ( lastIndex >= 0 ) && ( ( lastIndex + date_v2_String.length()) == date_v1_String.length()   );
		}
		 else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 ));  
			 
			 int lastIndex = s_v1.lastIndexOf(s_v2 );  
			 result = ( lastIndex >= 0 ) && ( ( lastIndex + s_v2.length()) == s_v1.length()   ); 
		}  
		return result;
	} 
	
	
	public static boolean between( Type dataType, Object o_v1, Object o_v2) throws Exception{
		boolean result = false;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		String object_string = String.valueOf(o_v2);
		if( UtilTools.IsNull( object_string ) ) {
			return result;
		}
		
		/* 支持,隔开 */
		String[] words = UtilTools.splitStringAndTrims( object_string, new String[]{",","，"});
		if( words == null ) return result;
		if( words.length != 2 ) return result;
		
		result = notLarger( dataType, o_v1, words[0]) && notLower( dataType, o_v1, words[1] );
		 
		return result;
	}
	
	public static boolean notBetween( Type dataType, Object o_v1, Object o_v2) throws Exception{
		boolean result = false;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		String object_string = String.valueOf(o_v2);
		if( UtilTools.IsNull( object_string ) ) {
			return result;
		}
		
		/* 支持,隔开 */
		String[] words = UtilTools.splitStringAndTrims( object_string, new String[]{",","，"});
		if( words == null ) return result;
		if( words.length != 2 ) return result;
		
		result = !( notLarger( dataType, o_v1, words[0]) && notLower( dataType, o_v1, words[1] ) );
		 
		return result;
	}
	
	 
	/**
	 * 处理小于等于
	 * @param dataType
	 * @param o_v1
	 * @param o_v2
	 * @return
	 * @throws Exception
	 */
	public static boolean notLower(Type dataType, Object o_v1, Object o_v2 ) throws Exception{
		boolean result = false;
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		if( dataType.equals( byte.class)){
			
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 >= byte_v2);
		}
		else if( dataType.equals(Byte.class)){
			byte byte_v1 = toByte(o_v1);
			byte byte_v2 = toByte(o_v2); 
			result = (byte_v1 >= byte_v2);
		}
		else if( dataType.equals(char.class)){
			 char char_v1 = toChar( o_v1 );
			 char char_v2 = toChar( o_v2 );
			 result =  ( char_v1 >= char_v2 );
		}   
		else if( dataType.equals( Short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 >= short_v2 );
		}	
		else if( dataType.equals( short.class)){
			short short_v1 = toShort( o_v1 );
			short short_v2 = toShort( o_v2 );
			result =  ( short_v1 >= short_v2 );
		} 
		else if(  dataType.equals( int.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 >= int_v2 );
		}
		else if(  dataType.equals( Integer.class)){
			int int_v1 = toInt( o_v1 );
			int int_v2 = toInt( o_v2 );
			result =  ( int_v1 >= int_v2 );
		}
		else if( dataType.equals( long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 >= long_v2 );
		}
		else if( dataType.equals( Long.class) ){
			long long_v1 = toLong( o_v1 );
			long long_v2 = toInt( o_v2 );
			result =  ( long_v1 >= long_v2 );
		} 
		else if( dataType.equals( float.class)){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = ( float_v1 > float_v2 ) || Math.abs(float_v1 - float_v2 ) < ZERO_FLOAT_VALUE_LIMMIT;
		}
		else if( dataType.equals(Float.class )){
			float float_v1 = toFloat( o_v1 );
			float float_v2 = toFloat( o_v2 );			
			result = ( float_v1 > float_v2 ) || Math.abs(float_v1 - float_v2 ) < ZERO_FLOAT_VALUE_LIMMIT;
		}
		else if( dataType.equals( double.class )){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = ( double_v1 > double_v2 ) || Math.abs( double_v1 - double_v2 ) < ZERO_DOUBLE_VALUE_LIMIT;
		}
		else if( dataType.equals( Double.class ) ){
			double double_v1 = toDouble( o_v1 );
			double double_v2 = toDouble( o_v2 );			
			result = ( double_v1 > double_v2 ) || Math.abs( double_v1 - double_v2 ) < ZERO_DOUBLE_VALUE_LIMIT;;
		}
		else if( dataType.equals( boolean.class )  ){
			 result = false;
		}
		else if( dataType.equals( Boolean.class )  ){ 
			result = false;
		}
		else if( dataType.equals( Date.class ) ){
			 Date date_v1 = toDate( o_v1 );
			 Date date_v2 = toDate( o_v2 );
			 return ( date_v1.getTime() - date_v2.getTime() >= 0);
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			Date date_v1 = toDate( o_v1 );
			Date date_v2 = toDate( o_v2 );
			return ( date_v1.getTime() - date_v2.getTime() >= 0);
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			java.sql.Time sqlTime_v1 = toSqlTime( o_v1 );
			java.sql.Time sqlTime_v2 = toSqlTime( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() >= 0);
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){ 
			java.sql.Timestamp sqlTime_v1 = toSqlTimestamp( o_v1 );
			java.sql.Timestamp sqlTime_v2 = toSqlTimestamp( o_v2 );
			return ( sqlTime_v1.getTime() - sqlTime_v2.getTime() >= 0);
		}
		else {
			 String s_v1 = UtilTools.Trim( String.valueOf( o_v1 ));
			 String s_v2 = UtilTools.Trim( String.valueOf( o_v2 )); 
			 result = ( s_v1.compareTo( s_v2 ) > 0 ) || s_v1.equals( s_v2 ) ; 
		} 
		return result;
	}

	
	public static boolean in( Type dataType, Object o_v1, Object o_v2) throws Exception{
		boolean result = false;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result; 
		
		String object_string = String.valueOf(o_v2);
		if( UtilTools.IsNull( object_string ) ) {
			return result;
		}
		
		/* 支持,隔开 */
		String[] words = UtilTools.splitStringAndTrims( object_string, new String[]{",","，"});
		if( words == null ) return result; 
		if( words.length == 0 ) return result; 
		
		result = true;
		for( String word : words ){
			if(!equals( dataType, o_v1, word )){
				result = false;
				break;
			}
		}
		return result;
	}
	
	public static boolean notIn( Type dataType, Object o_v1, Object o_v2) throws Exception{
		boolean result = false;
		
		if(dataType == null ) return result;
		if( o_v1 == null ) return result;
		if( o_v2 == null ) return result;
		
		String object_string = String.valueOf(o_v2);
		if( UtilTools.IsNull( object_string ) ) {
			return result;
		}
		
		result = !in(dataType, o_v1, o_v2);
		return result;
	}
	
	
	/**
	 * 根据value 设置值
	 * @param dataType
	 * @param valueString
	 * @return
	 */
	public static Object parserValue( Type dataType, String valueString){
		Object result = null;
		
		if( dataType == null ) return result; 
		
		if( dataType.equals( byte.class)){
			result = (byte)UtilTools.getIntgerValue( valueString );
		}
		else if( dataType.equals(Byte.class)){
			result = (byte)UtilTools.getIntgerValue( valueString );
		}
		else if( dataType.equals(char.class)){
			result = (char)UtilTools.getIntgerValue( valueString );
		}  
		else if( dataType.equals( Short.class)){
			result = (short)UtilTools.getIntgerValue( valueString );
		}	
		else if( dataType.equals( short.class)){
			result = (short)UtilTools.getIntgerValue( valueString );
		} 
		else if(  dataType.equals( int.class)){
			result = UtilTools.getIntgerValue( valueString );
		}
		else if(  dataType.equals( Integer.class)){
			result = UtilTools.getIntgerValue( valueString );
		}
		else if( dataType.equals( long.class) ){
			result = UtilTools.getLongValue( valueString );
		}
		else if( dataType.equals( Long.class) ){
			result = UtilTools.getLongValue( valueString );
		} 
		else if( dataType.equals( float.class)){
			result = UtilTools.getFloatValue(valueString);
		}
		else if( dataType.equals(Float.class )){
			result = UtilTools.getFloatValue(valueString);
		}
		else if( dataType.equals( double.class )){
			result = UtilTools.getDoubleValue(valueString);
		}
		else if( dataType.equals( Double.class ) ){
			result = UtilTools.getDoubleValue(valueString);
		}
		else if( dataType.equals( boolean.class )  ){
			result = UtilTools.getBooleanValue(valueString);
		}
		else if( dataType.equals( Boolean.class )  ){
			result = UtilTools.getBooleanValue(valueString);
		}
		else if( dataType.equals( Date.class ) ){
			result = UtilTools.toDate( valueString );
		}
		else if( dataType.equals( java.sql.Date.class ) ){
			result = UtilTools.toDate( valueString );
		}
		else if( dataType.equals( java.sql.Time.class ) ){
			result = UtilTools.toSqlTime( valueString );
		}
		else if( dataType.equals( java.sql.Timestamp.class ) ){
			result = UtilTools.toSqlTimestamp( valueString );
		}
		 else {
			result = UtilTools.Trim( valueString );
		}
		return result;
	}
	

	public static byte toByte(Object o_value ) throws Exception{
		byte result = 0;
		
		if( o_value == null ) return result;
		
		if( o_value instanceof String ){
			result = (byte)UtilTools.getIntgerValue((String) o_value);
		}else if( o_value instanceof java.util.Date){
			result = (byte)( (java.util.Date)o_value).getTime();
		}else if( o_value instanceof Byte){
			result = (Byte)o_value;
		}else if( o_value instanceof Integer){
			result = (Byte)o_value;
		}else if( o_value instanceof Long){
			result = (Byte)o_value;
		}else {
			result = (byte)UtilTools.getIntgerValue( String.valueOf( o_value));
		}
		
		return result;
	}
	
	public static short toShort(Object o_value ) throws Exception{
		short result = 0;
		
		if( o_value == null ) return result;
		
		if( o_value instanceof String ){
			result = (short)UtilTools.getIntgerValue((String) o_value);
		}else if( o_value instanceof java.util.Date){
			long nv = ( (java.util.Date)o_value).getTime();
			result = UtilTools.getShortValue( String.valueOf(nv));
		}else if( o_value instanceof Short){
			result = (Short)o_value;
		}else if( o_value instanceof Integer){
			result = UtilTools.getShortValue( String.valueOf(o_value));
		}else if( o_value instanceof Long){
			result = UtilTools.getShortValue( String.valueOf(o_value));
		}else {
			result = (short)UtilTools.getIntgerValue( String.valueOf( o_value));
		}
		
		return result;
	}
	
	public static char toChar(Object o_value ) throws Exception{
		char result = 0;
		
		if( o_value == null ) return result;
		
		if( o_value instanceof String ){
			result = (char)UtilTools.getIntgerValue((String) o_value);
		}else if( o_value instanceof java.util.Date){
			result = (char) UtilTools.getByteValue( String.valueOf(
					( (java.util.Date)o_value).getTime()));
		}else if( o_value.getClass().equals( char.class ) ){
			result = (char)o_value;
		}else if( o_value instanceof Short){  
			result =  (char) UtilTools.getByteValue( String.valueOf(o_value));
		}else if( o_value instanceof Integer){
			result =  (char) UtilTools.getByteValue( String.valueOf(o_value));
		}else if( o_value instanceof Long){
			result =  (char) UtilTools.getByteValue( String.valueOf(o_value));
		}
		else {
			result = (char)UtilTools.getIntgerValue( String.valueOf( o_value));
		}
		
		return result;
	}
	
	public static int toInt(Object o_value ) throws Exception{
		int result = -1;
		if( o_value == null ) return result;
		
		if( o_value instanceof String ){
			result =  UtilTools.getIntgerValue((String) o_value);
		}else if( o_value instanceof java.util.Date){
			result = UtilTools.getIntgerValue( String.valueOf(
					( (java.util.Date)o_value).getTime()));
		}else if( o_value instanceof Short){
			result =  UtilTools.getIntgerValue( String.valueOf(o_value));
		}else if( o_value instanceof Integer){
			result = (int)o_value;
		}else if( o_value instanceof Long){
			result =  UtilTools.getIntgerValue( String.valueOf(o_value));
		}else if( o_value instanceof Byte){
			result =  UtilTools.getIntgerValue( String.valueOf(o_value));
		}
		else {
			result =  UtilTools.getIntgerValue( String.valueOf( o_value));
		} 
		return result;
	}
	
	public static long toLong( Object o_value ) throws Exception{
		long result = -1;
		if( o_value == null ) return result;
		
		if( o_value instanceof String ){
			result =  UtilTools.getLongValue((String) o_value);
		}
		else if( o_value instanceof java.util.Date){
			result = ( (java.util.Date)o_value).getTime();
		}
		else if( o_value instanceof Short){
			result = (Long)o_value;
		}
		else if( o_value instanceof Integer){
			result = (Long)o_value;
		}
		else if( o_value instanceof Long){
			result = (Long)o_value;
		}
		else if( o_value instanceof Byte){
			result = (Long)o_value;
		}else {
			result =  UtilTools.getLongValue( String.valueOf( o_value));
		}  
		return result;
	}
	
	public static float toFloat( Object o_value ) throws Exception{
		float result = -1.0f;
		
		if( o_value == null ) return result;
		
		if( o_value instanceof String ){
			result =  UtilTools.getFloatValue(String.valueOf( o_value) );
		}else if( o_value instanceof java.util.Date){
			result = ( (java.util.Date)o_value).getTime();
		}
		else if( o_value instanceof Short){
			result = (Float)o_value;
		}
		else if( o_value instanceof Integer){
			result = (Float)o_value;
		}
		else if( o_value instanceof Long){
			result = (Float)o_value;
		}
		else if( o_value instanceof Byte){
			result = (Float)o_value;
		}
		else if( o_value instanceof Float){
			result = (Float)o_value;
		}
		else if( o_value instanceof Double){
			result = (Float)o_value;
		}
		else{
			result = UtilTools.getFloatValue(String.valueOf( o_value)) ; 
			
		}  
		return result;
	}
	
	public static double toDouble( Object o_value ) throws Exception{
		double result = -1.0;
		
		if( o_value == null ) return result;
		
		if( o_value instanceof String ){
			result = UtilTools.getDoubleValue(String.valueOf( o_value) );
		}else if( o_value instanceof java.util.Date){
			result = ( (java.util.Date)o_value).getTime();
		}
		else if( o_value instanceof Short){
			result = (Double)o_value;
		}
		else if( o_value instanceof Integer){
			result = (Double)o_value;
		}
		else if( o_value instanceof Long){
			result = (Double)o_value;
		}
		else if( o_value instanceof Byte){
			result = (Double)o_value;
		}
		else if( o_value instanceof Float){
			result = (Double)o_value;
		}
		else if( o_value instanceof Double){
			result = (Double)o_value;
		}
		else{
			result = UtilTools.getDoubleValue(String.valueOf( o_value) );
		}
		return result;
	}
	
	public static Date toDate( Object o_value ) throws Exception{
		Date result = null;
		
		if( o_value instanceof String ){
			result = UtilTools.toDate( (String) o_value );
		}else if( o_value instanceof java.util.Date){
			result = (java.util.Date)o_value;
		}
		else if( o_value instanceof Short){
			result = new java.util.Date( (long)o_value ) ;
		}
		else if( o_value instanceof Integer){
			result = new java.util.Date((long)o_value) ;
		}
		else if( o_value instanceof Long){
			result = new java.util.Date((long)o_value) ;
		}
		else if( o_value instanceof Byte){
			result = new java.util.Date((long)o_value) ;
		}
		else {
			result = UtilTools.toDate( String.valueOf( o_value));
		} 
		
		return result;
	}
	
	public static java.sql.Time toSqlTime( Object o_value ) throws Exception{
		java.sql.Time result = null;
		
		if( o_value instanceof String ){
			result = UtilTools.toSqlTime( (String) o_value );
		}else if( o_value instanceof java.util.Date){
			result = new java.sql.Time( ( (java.util.Date)o_value).getTime());
		}
		else if( o_value instanceof Short){
			result = new java.sql.Time( (long)o_value ) ;
		}
		else if( o_value instanceof Integer){
			result = new java.sql.Time((long)o_value) ;
		}
		else if( o_value instanceof Long){
			result = new java.sql.Time((long)o_value) ;
		}
		else if( o_value instanceof Byte){
			result = new java.sql.Time((long)o_value) ;
		}
		else {
			result = UtilTools.toSqlTime( String.valueOf( o_value));
		} 
		
		return result;
	}
	
	public static java.sql.Timestamp toSqlTimestamp( Object o_value ) throws Exception{
		java.sql.Timestamp result = null;
		
		if( o_value instanceof String ){
			result = UtilTools.toSqlTimestamp( (String) o_value );
		}else if( o_value instanceof java.util.Date){
			result = new java.sql.Timestamp( ( (java.util.Date)o_value).getTime());
		}
		else if( o_value instanceof Short){
			result = new java.sql.Timestamp( (long)o_value ) ;
		}
		else if( o_value instanceof Integer){
			result = new java.sql.Timestamp((long)o_value) ;
		}
		else if( o_value instanceof Long){
			result = new java.sql.Timestamp((long)o_value) ;
		}
		else if( o_value instanceof Byte){
			result = new java.sql.Timestamp((long)o_value) ;
		}
		else {
			result = UtilTools.toSqlTimestamp( String.valueOf( o_value));
		}  
		return result;
	}  
	
	public static boolean toBoolean( Object o_value ) throws Exception{
		Boolean result = null;
		
		if( o_value instanceof String ){
			result = Boolean.parseBoolean( (String) o_value );
		}else if( o_value instanceof java.util.Date){
			result = false;
		}else if( o_value instanceof Short){
			result =  ((int)o_value )==1 ;
		}
		else if( o_value instanceof Integer){
			result = ((int)o_value )==1;
		}
		else if( o_value instanceof Long){
			result = ((int)o_value )==1 ;
		}
		else if( o_value instanceof Byte){
			result = ((int)o_value )==1 ;
		}else {
			result = Boolean.parseBoolean( String.valueOf( o_value));
		} 
		
		return result;
	}


	/**
	 * 将对象的方法，及值填充到map(当前层）
	 * @param map
	 * @param obj
	 * @throws Excetpion
	 */
	public static Object getObjectMethodValue( Object obj, String fieldName ) throws Exception{
		Object result = null; 
		 
		if( obj == null ) return result;
		if( UtilTools.IsNull( fieldName) ) return result;
		 
		Method[] methods = obj.getClass().getMethods();
		if( methods == null ) return result;
		if( methods.length == 0 ) return result;
		
		String _t_fieldName = UtilTools.Trim( fieldName );
		
		for( Method _method : methods){
			String method_name = UtilTools.Trim( _method.getName() );
			try{
				if( method_name.indexOf("get") == 0 ){
					String key_name = UtilTools.Trim( method_name.substring( "get".length())  );
					if( UtilTools.IsNull( key_name )) continue;
					
					if( key_name.equalsIgnoreCase(_t_fieldName)){
						/* 执行 */
						result = _method.invoke(obj );
						break;
					} 
				}
			}catch(Exception e){
				
			}
		}		
		
		return result;
	}
	
	/**
	 * 将对象的方法，及值填充到map(当前层）
	 * @param map
	 * @param obj
	 * @throws Excetpion
	 */
	public static void setObjectMethodValue( Object obj, String fieldName, Object _new_value ) throws Exception{
		if( obj == null ) return ;
		if( UtilTools.IsNull( fieldName) ) return ;
		 
		Method[] methods = obj.getClass().getMethods();
		if( methods == null ) return  ;
		if( methods.length == 0 ) return  ;
		
		String _t_fieldName = UtilTools.Trim( fieldName );
		
		for( Method _method : methods){
			String method_name = UtilTools.Trim( _method.getName() );
			try{
				if( method_name.indexOf("set") == 0 ){
					String key_name = UtilTools.Trim( method_name.substring( "set".length())  );
					if( UtilTools.IsNull( key_name )) continue;
					
					if( key_name.equalsIgnoreCase(_t_fieldName)){
						/* 执行 */
						_method.invoke(obj, _new_value );
						break;
					} 
				}
			}catch(Exception e){
				
			}
		}		 
	}

}